package com.huawei.appgallery.search.ui.node;

import android.content.Context;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.text.style.TypefaceSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.search.ui.card.HotWordBaseCard;
import com.huawei.appgallery.search.ui.card.RelatedWordsAddWishCard;
import o.chy;
import o.cuv.a;
import o.cuv.b;
import o.cuv.d;
import o.cuv.e;
import o.cuv.f;
import o.evx;

public class RelatedWordsAddWishNode extends HotWordBaseNode {
    View ˊ;

    public RelatedWordsAddWishNode(Context context) {
        super(context);
    }

    public boolean ˊ(ViewGroup viewGroup, ViewGroup viewGroup2) {
        boolean ˊ = super.ˊ(viewGroup, viewGroup2);
        LinearLayout linearLayout = (LinearLayout) viewGroup.findViewById(b.ˈ);
        linearLayout.setPadding(linearLayout.getPaddingLeft(), this.ॱ.getResources().getDimensionPixelSize(a.ˎ), linearLayout.getPaddingRight(), this.ॱ.getResources().getDimensionPixelSize(a.ᐝ));
        ˎ(linearLayout);
        return ˊ;
    }

    private void ˎ(LinearLayout linearLayout) {
        this.ˊ = LayoutInflater.from(this.ॱ).inflate(e.ᐝॱ, null);
        TextView textView = (TextView) this.ˊ.findViewById(b.ˋ);
        linearLayout.addView(this.ˊ);
        String string = this.ॱ.getString(f.ʿ);
        CharSequence spannableString = new SpannableString(this.ॱ.getString(f.ˈ, new Object[]{string}));
        int indexOf = spannableString.toString().indexOf(string);
        spannableString.setSpan(new ForegroundColorSpan(this.ॱ.getResources().getColor(d.ˊ)), indexOf, string.length() + indexOf, 33);
        spannableString.setSpan(new TypefaceSpan(this.ॱ.getResources().getString(f.ˏ)), indexOf, string.length() + indexOf, 33);
        textView.setText(spannableString);
    }

    public void ˋ(final chy o_chy) {
        super.ˋ(o_chy);
        if (this.ˊ != null) {
            this.ˊ.setOnClickListener(new evx(this) {
                final /* synthetic */ RelatedWordsAddWishNode ˎ;

                public void ˋ(View view) {
                    if (o_chy != null) {
                        o_chy.ˏ(8, this.ˎ.ˎ(0));
                    }
                }
            });
        }
    }

    protected HotWordBaseCard ˏ(Context context) {
        return new RelatedWordsAddWishCard(context);
    }
}
